#!/bin/bash
# 修改 root 密码
echo "rocky:rocky" | chpasswd
# 启用 SSH 密码登录和 root 权限
sed -i 's/^#\?PermitRootLogin.*/PermitRootLogin yes/g' /etc/ssh/sshd_config
sed -i 's/^#\?PasswordAuthentication.*/PasswordAuthentication yes/g' /etc/ssh/sshd_config
# 重启 SSH 服务
systemctl restart sshd